package Package.SpecialActionFlow.CharacterPrintStream;

import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class CharacterPrintStream {
    public static final void CharacterPrintStream() throws IOException {
//        字符打印流构造房方法
//        PrintWriter(StringfileName) 使用指定的文件名创建一个新的PrintWriter，而不需要自动执行刷新
        PrintWriter pw = new PrintWriter("D:\\insert\\a.txt");
        pw.write("Hello");
        pw.write("\r\n");
        pw.flush();
        pw.write("world");
        pw.write("\r\n");
        pw.flush();
        System.out.println("---------------------------");
        pw.println("hello");
//        PrintWriter(Writer out, booleanautoFlush)创建一个新的PrintWriter out：字符输出流 autoFlush： 一个布尔值，如果为真，则println ， printf ，或format方法将刷新输出缓冲区
    PrintWriter Pw=new PrintWriter(new FileWriter("D:\\insert\\B.txt"),true);
        Pw.println("hello");
        Pw.println("world");
        Pw.close();

    }
}
